#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5;
const int M = 1e9 + 7;

int l, q, c, x;
set<int> s;

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> l >> q;
    s.insert(0);
    s.insert(l);
    while (q--)
    {
        cin >> c >> x;
        if (c == 1)
            s.insert(x);
        else if (c == 2)
        {
            auto left = s.upper_bound(x), right = s.lower_bound(x);
            left--;
            cout << *right - *left  << endl;
        }
    }
    return 0;
}